#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
const int N=2e5+5;
int T,n,a[N],ans,co;
map<int,int> ma;
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        ma.clear();
        scanf("%d",&n);
        ans=0,co=-1;
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(int i=1;i<=n;i++){
            ma[a[i]]++;
            if(ma[a[i]]>=2)
                ans+=a[i];
        }
        printf("%d\n",ans);
    }
    return 0;
}
